home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / unixcpio.gz / unixnet.cpio / ecvec.asm < prev    next >
Assembly Source File  |  1994-07-11  |  2KB  |  89 lines

  1.     include    pmacros.h
  2.  
  3.     inthandler    ec, 0
  4.     inthandler    ec, 1
  5.     inthandler    ec, 2
  6.  
  7. ; fast buffer I/O routines -- used by 3-COM Ethernet controller
  8.  
  9. ; outbuf - put a buffer to an output port
  10.     procdef outbuf,<<oport,word>,<obuf,ptr>,<ocnt,word>>
  11.     pushf
  12.     push    si
  13.     pushds
  14.     mov    dx,oport
  15.     mov    cx,ocnt
  16.     ldptr    si,obuf,ds    ; ds:si = obuf
  17.     cld
  18.  
  19. ; If buffer doesn't begin on a word boundary, send the first byte
  20.     test    si,1    ; (buf & 1) ?
  21.     jz    obufeven ; no
  22.     lodsb        ; al = *si++;
  23.     out    dx,al    ; out(dx,al);
  24.     dec    cx    ; cx--;
  25.     mov    ocnt,cx    ; save for later test
  26. obufeven:
  27.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  28. ; Do the bulk of the buffer, a word at a time
  29.     jcxz    onobuf    ; if(cx != 0){
  30. xb:    lodsw        ; do { ax = *si++; (si is word pointer)
  31.     out    dx,al    ; out(dx,lowbyte(ax));
  32.     mov    al,ah
  33.     out    dx,al    ; out(dx,hibyte(ax));
  34.     loop    xb    ; } while(--cx != 0); }
  35. ; now check for odd trailing byte
  36. onobuf:    mov    cx,ocnt
  37.     test    cx,1
  38.     jz    ocnteven
  39.     lodsb        ; al = *si++;
  40.     out    dx,al
  41. ocnteven:
  42.     popds
  43.     pop    si
  44.     popf
  45.     pret
  46.     pend    outbuf
  47.  
  48. ; inbuf - get a buffer from an input port
  49.     procdef inbuf,<<iport,word>,<ibuf,ptr>,<icnt,word>>
  50.     pushf
  51.     push    di
  52.     pushes
  53.     mov    dx,iport
  54.     mov    cx,icnt
  55.     ldptr    di,ibuf,es    ; es:di = ibuf (es already set in small model)
  56.     cld
  57.  
  58. ; If buffer doesn't begin on a word boundary, get the first byte
  59.     test    di,1    ; if(buf & 1){
  60.     jz    ibufeven ;
  61.     in    al,dx    ; al = in(dx);
  62.     stosb        ; *di++ = al
  63.     dec    cx    ; cx--;
  64.     mov    icnt,cx    ; icnt = cx; } save for later test
  65. ibufeven:
  66.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  67. ; Do the bulk of the buffer, a word at a time
  68.     jcxz    inobuf    ; if(cx != 0){
  69. rb:    in    al,dx    ; do { al = in(dx);
  70.     mov    ah,al
  71.     in    al,dx    ; ah = in(dx);
  72.     xchg    al,ah
  73.     stosw        ; *si++ = ax; (di is word pointer)
  74.     loop    rb    ; } while(--cx != 0);
  75. ; now check for odd trailing byte
  76. inobuf:    mov    cx,icnt
  77.     test    cx,1
  78.     jz    icnteven
  79.     in    al,dx
  80.     stosb        ; *di++ = al
  81. icnteven:
  82.     popes
  83.     pop    di
  84.     popf
  85.     pret
  86.     pend    inbuf
  87.  
  88.     end
  89.